package com.threeti.jiayusms.interfaces.ws.communicationfunction;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.CommunicationFunction;
import com.threeti.jiayusms.domain.service.communicationfunction.CommunicationFunctionQueryService;

@WebService(serviceName = "FunctionTemplateService", portName = "FunctionTemplateServicePort", 
		endpointInterface = "com.threeti.jiayusms.interfaces.ws.communicationfunction.FunctionTemplateWebService", 
		targetNamespace = "http://127.0.0.1:8080/sms-maintenance-main" )
@Transactional
public class FunctionTemplateWebServiceDelegate implements FunctionTemplateWebService {

	@Autowired
	private CommunicationFunctionQueryService queryService;
	
	@Override
	public CommunicationFunctionDto findCommunicationFunctionBy(String functionId) {
		CommunicationFunction functionTemplate = queryService.findCommunicationFunctionBy(functionId);
		
		if(functionTemplate == null){
			return null;
		}
		CommunicationFunctionDto dto = new CommunicationFunctionDto(functionTemplate.getFunctionType(),
				functionTemplate.getFunctionName(),
				functionTemplate.getAssociatedField(),
				functionTemplate.getRelationTable(),
				functionTemplate.getRelationField(),
				functionTemplate.getFunctionContent(),
				functionTemplate.getActiveFlag(),
				functionTemplate.getDescription());
		return dto;
	}
	
	@Override
	public List<CommunicationFunctionDto> findCommunicationFunctionByList(){
		List<CommunicationFunctionDto> dto = new ArrayList<CommunicationFunctionDto>();
		
		return dto;
	}
	
}
